#pragma once
#include <cstdio>
#include <iostream>
#include <string>
#include <functional>
class Task
{
public:
    typedef std::function<int(int, int, char)> func_t;
    Task() = default;
    Task(int x, int y, char op, func_t func)
        :_x(x)
        ,_y(y)
        ,_op(op)
        ,_func(func)
    {}
    std::string ToString()
    {
        char buffer[64];
        snprintf(buffer, sizeof(buffer), "%d %c %d = ?", _x, _op, _y);
        return buffer;
    }
    std::string operator()()
    {
        char buffer[64];
        int ret = _func(_x, _y, _op);
        snprintf(buffer, sizeof(buffer), "%d %c %d = %d", _x, _op, _y, ret);
        return buffer;
    }
private:
    int _x;
    int _y;
    char _op;
    func_t _func;
};

std::string operations = "+-*/%";
int MyMath(int a, int b, char op)
{
    int ret = 0;
    switch(op)
    {
        case '+':
            ret = a + b;
            break;
        case '-':
            ret = a - b;
            break;
        case '*':  
            ret = a * b;
            break;
        case '/':
            {
                if(0 == b)  std::cerr << "division zero error" << std::endl;
                ret = -1;
            }
            break;
        case '%':
            {
                if(0 == b) std::cerr << "mod zero error" << std::endl;
            }           
        default:
            // do nothing
            break;
    }
    return ret;
}